package com.leetcode.math;

import java.util.ArrayList;
import java.util.List;

public class GeLeiMa {
    public static void main(String[] args) {
        GeLeiMa geLeiMa = new GeLeiMa();
        System.out.println(geLeiMa.solve(3, 5));
    }

    public String solve(int n, int k) {
        List<String> list = new ArrayList<>();
        list.add("0");
        list.add("1");
        for (int i = 2; i <= n; i++) {
            List<String> tmpList = new ArrayList<>(list);
            for (int j = 0; j < list.size(); j++) {
                list.set(j, "0" + list.get(j));
            }
            for (int j = tmpList.size() - 1; j >= 0; j--) {
                list.add("1" + tmpList.get(j));
            }
        }

        return list.get(k);
    }
}
